<template>
	<view>
		<check-update :data="data" @cancel="cancel" @downloadComplete="downloadComplete"></check-update>
	</view>
</template>

<script setup>
	import CheckUpdate from "@/components/rt-uni-update/components/rt-uni-update/rt-uni-update.vue"
	import {
		onLoad,
		onHide,
		onBackPress
	} from '@dcloudio/uni-app';
	import {
		reactive,
		onMounted
	} from "vue"
	// import {
	// 	checkAppVersion
	// } from "@/utils/function.js"
	const emits = defineEmits(["cancel"])
	const data = reactive({
		version: '0.0.0', //当前运行版本(打包时manifest里的版本名称)
		percent: 0, //进度条百分比
		updateBtn: true, //是否显示立即更新
		cancleBtn: true, //是否显示取消按钮
		downloadedSize: 0, //当前已下载大小
		packageFileSize: 0, //安装包大小
		data: {
			describe: '',
			edition_url: '', //安装包下载地址或者通用应用市场地址
			edition_force: 0, //是否强制更新 0代表否 1代表是
			package_type: 0, //0是整包升级 1是wgt升级
			edition_name: '0.0.0' //后端返回的版本名称
		}
	})

	onMounted(() => {
		plus.runtime.getProperty(plus.runtime.appid, (inf) => {
			data.version = inf.version;
		})
		// checkAppVersion().then(res => {
		// 	data.data = res
		// }).catch(() => {})
	})

	function cancel() {
		emits("cancel")
	}
	
	function downloadComplete() {
		setTimeout(() => {
			cancel()
		}, 1000)
	}
</script>

<style>

</style>